//
//  WaterAPI.m
//  Water
//
//  Created by yh on 2017/11/30.
//  Copyright © 2017年 chenguibang. All rights reserved.
//

#import "WaterAPI.h"


@implementation WaterAPI


+ (void)getWeater:(NSString *)city
         progress:(void (^)(NSProgress * progress))downloadProgress
          success:(void (^)(NSURLSessionDataTask * task , id responesObject))success
          failure:(void (^)(NSURLSessionDataTask * task, NSError * error))failure{
//    ApiRequest *requst = [ApiRequest requestWith:@{@"city":city}];
//    requst.serverUrl = @"http://wthrcdn.etouch.cn";
//    requst.apiInterface = @"/WaterAPI?";
//    requst.showMsg = NO;
//
    APiSessionManager *manager = [APiSessionManager shared];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    
    [manager GET:@"http://wthrcdn.etouch.cn/WaterAPI" parameters:@{@"city":city} progress:downloadProgress success:success failure:failure];
}

+ (void)addDrinkRecord:(DrinkRecord *)drinkRecord
              progress:(void (^)(NSProgress * progress))downloadProgress
               success:(void (^)(ApiResponse *response))success
               failure:(void (^)(NSURLSessionDataTask * task, NSError * error))failure{
    WaterRequest *requst = [WaterRequest requestWith:drinkRecord];
    requst.showMsg = NO;
    requst.apiInterface = @"/api/water/records/add";
    [[APiSessionManager shared] API_GET:requst progress:downloadProgress success:success failure:failure];
}


+ (void)recordsWith:(RecordsParam *)recordsParam
              progress:(void (^)(NSProgress * progress))downloadProgress
               success:(void (^)(ApiResponse *response))success
               failure:(void (^)(NSURLSessionDataTask * task, NSError * error))failure{
    WaterRequest *requst = [WaterRequest requestWith:recordsParam];
    requst.showMsg = NO;
    requst.apiInterface = @"/api/water/records/get";
    [[APiSessionManager shared] API_GET:requst progress:downloadProgress success:success failure:failure];
}

@end
